import { GetManyDefaultResponse } from '../interfaces/get-many-default-response.interface'

function createPageInfo<T> (
  data: T[],
  page: number,
  total: number,
  limit: number,
): GetManyDefaultResponse<T> {
  return {
    data,
    pageSize: limit,
    totalAccount: total,
    pageNo: page,
    totalPage:
      limit && total
        ? Math.ceil(total / limit)
        : /* istanbul ignore next line */
          undefined,
  };
}

export { createPageInfo }